<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%String contextPath = request.getContextPath();%>
<!DOCTYPE html>
<html>
<body>
<img id="loading" src="<%=contextPath%>/jslib/easyui/extension/images/loading.gif" style="display:none;">

<div style="padding:10px 20px">
    <form id="fm" method="post" action="" enctype="multipart/form-data" novalidate>
        <input id="organFile" type="file" name="organFile">

        <div style="color: red;padding-top: 4px;">导入格式请参考机构模板</div>
    </form>
</div>
<script type="text/javascript">
    function sy_ExcelImport($dialog, $grid, $pjq, $menuTree) {
        $.messager.progress({
            text: '数据上传中....'
        });
        $.ajaxFileUpload({
                    url: '<%=contextPath%>/sys/organization/importExcel',             //需要链接到服务器地址
                    secureuri: false,
                    fileElementId: 'organFile',                         //文件选择框的id属性
                    dataType: 'json',                                     //服务器返回的格式，可以是json
                    success: function (data, status)             //相当于java中try语句块的用法
                    {
                        $.messager.progress('close');
                        if(data.value != ""){
                            $.messager.alert("操作提示", "成功导入"+data.count+"条信息!"+data.value);
                        }else{
                            $.messager.alert("操作提示", "导入完成，成功导入"+data.count+"条信息！");
                        }
                        //刷新datagrid
                        try {
                            $grid.datagrid('load');
                            $grid.datagrid('clearSelections');
                            $grid.datagrid('clearChecked');
                            $grid.treegrid('load');
                        } catch (e) {

                        }
                        try {
                            if ($menuTree) {
                                $menuTree.tree("reload");//加载树
                            }
                        } catch (e) {

                        }
                        $dialog.dialog('destroy');
                    },
                    error: function (data, status, e)             //相当于java中catch语句块的用法
                    {
                        $.messager.progress('close');
                        $.messager.alert("操作提示", "导入失败");
                    }
                }
        );
    }
</script>
</body>
</html>